window.addEventListener("load",function(){
	var xhr=new XMLHttpRequest();
	xhr.open("GET","../data/categories.json",true);
	//xhr.responseType="json";
	xhr.addEventListener("load",function(){
		var json=JSON.parse(xhr.responseText);
		var list=document.getElementById("list");
		for(var i=0;i<json.categories.length;i++)
		{
			var item=document.createElement("li");
			item.style="border-style: solid; border-color: green;";
			var img=document.createElement("img");
			img.src=json.categories[i].icon;
			img.style="width: 64px; height: 64px;";
			var h3=document.createElement("h3");
			h3.textContent=json.categories[i].name;
			
			item.addEventListener("click",function(){
				sessionStorage.itemCategory=json.categories[i].name;
				window.location.href=json.categories[i].html;
			});
			item.appendChild(img);
			item.appendChild(h3);
			list.appendChild(item);
		}
	});
	xhr.send();
});
